//
//  MyselfHeaderView.m
//  Lucky28
//
//  Created by zr on 2018/8/1.
//  Copyright © 2018年 zr. All rights reserved.
//

#import "MyselfHeaderView.h"


@interface MyselfHeaderView ()

@property(nonatomic, weak)UIImageView * backImageView;
@property(nonatomic, weak)UIImageView * iconImageView;
@property(nonatomic, weak)UILabel * nameLabel;
@property(nonatomic, weak)UILabel * likeLabel;
@property(nonatomic, weak)UILabel * getLikeLabel;
@property(nonatomic, weak)UILabel * collectionLabel;


@end

@implementation MyselfHeaderView


- (void)setUrl:(NSURL *)url{
    
    _url = url;
    
    [self.iconImageView sd_setImageWithURL:url placeholderImage:ImageNamed(@"头像7")];
}

-(void)setNameString:(NSString *)nameString{
    
    _nameString = nameString;
    
    self.nameLabel.text = nameString;
}

- (void)setBirString:(NSString *)birString{
    
    _birString = birString;
    
    self.likeLabel.text = [NSString stringWithFormat:@" %@ ",birString];
}

- (void)setCityString:(NSString *)cityString{
    
    _cityString = cityString;
    if (cityString.length < 1) {
        
        NSString * str = @"高新区";
        self.collectionLabel.text = [NSString stringWithFormat:@" %@ ",str];
    }else{
        
        self.collectionLabel.text = [NSString stringWithFormat:@" %@ ",cityString];
    }
    
}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    return self;
}


- (void)setupUI{
    
    self.backgroundColor = [UIColor whiteColor];
    
    
    UIImageView * backImageView = [UIImageView new];
    
    backImageView.image = ImageNamed(@"212325wsww");
//    backImageView.backgroundColor = [UIColor grayColor];
    
    self.backImageView = backImageView;
    
    [self addSubview:self.backImageView];
    
    
    UIImageView * iconImageView = [UIImageView new];
    
    //  把图片设置成圆形
    iconImageView.layer.cornerRadius = 31;//裁成圆角
    iconImageView.layer.masksToBounds = YES;//隐藏裁剪掉的部分

    iconImageView.image = ImageNamed(@"23sdasas");
//    iconImageView.backgroundColor = [UIColor redColor];
    
    self.iconImageView = iconImageView;
    
    [self.backImageView addSubview:self.iconImageView];
    
    
    UILabel * nameLabel = [UILabel new];
    
    nameLabel.text = @"用户姓名";
    nameLabel.textColor = WHITE_COLOR;
    nameLabel.font = [UIFont systemFontOfSize:15 * SCREENH6];
    
    self.nameLabel = nameLabel;
    
    [self.backImageView addSubview:self.nameLabel];
    
    
    UILabel * likeLabel = [UILabel new];
    
    likeLabel.text = @" 22岁 ";
    likeLabel.textColor = WHITE_COLOR;
    likeLabel.backgroundColor = ColorWithRGB(0xEFBFF2);
    likeLabel.font = [UIFont systemFontOfSize:14 * SCREENH6];
    
    self.likeLabel = likeLabel;
    
    [self.backImageView addSubview:self.likeLabel];

    
    UILabel * getLikeLabel = [UILabel new];
    
    getLikeLabel.text = @" 处女座 ";
    getLikeLabel.textColor = WHITE_COLOR;
    getLikeLabel.backgroundColor = ColorWithRGB(0xA4CD32);
    getLikeLabel.font = [UIFont systemFontOfSize:14 * SCREENH6];
    
    self.getLikeLabel = getLikeLabel;
    
    [self.backImageView addSubview:self.getLikeLabel];
    
    
    UILabel * collectionLabel = [UILabel new];
    
    collectionLabel.text = @" 六合区 ";
    collectionLabel.textColor = WHITE_COLOR;
    collectionLabel.backgroundColor = ColorWithRGB(0xB1302E);
    collectionLabel.font = [UIFont systemFontOfSize:14 * SCREENH6];
    
    self.collectionLabel = collectionLabel;
    
    [self.backImageView addSubview:self.collectionLabel];
}


- (void)layoutSubviews{

    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.bottom.mas_equalTo(self);
    }];
    
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.backImageView).offset(80 * SCREENH6);
        make.leading.mas_equalTo(self.backImageView).offset(10 * SCREENH6);
        make.height.width.mas_equalTo(62 * SCREENH6);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.iconImageView.mas_trailing).offset(15 * SCREENH6);
        make.centerY.mas_equalTo(self.iconImageView).offset(-10 * SCREENH6);
    }];
    
    [self.likeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.nameLabel);
        make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(10 * SCREENH6);
    }];

    [self.getLikeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.likeLabel.mas_trailing).offset(8 * SCREENH6);
        make.centerY.mas_equalTo(self.likeLabel);
    }];

    [self.collectionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.getLikeLabel.mas_trailing).offset(8 * SCREENH6);
        make.centerY.mas_equalTo(self.getLikeLabel);
    }];
}


- (UILabel *)setupLabelWith:(NSString *)string{
    
    UILabel * label = [UILabel new];
    
    label.text = string;
    label.textColor = ColorWithRGB(0x909090);
    label.font = [UIFont systemFontOfSize:15 * SCREENH6];
    
    
    return label;
}

- (UIView *)setupLineView{
    
    UIView * lineView = [UIView new];
    
    lineView.backgroundColor = ColorWithRGB(0x909090);
    
    
    return lineView;
}


@end
